/**
 * Copyright (c) 2016-2019 九点科技 All rights reserved.
 *
 * http://www.9dyun.cn
 *
 * 版权所有，侵权必究！
 */
package com.dian.modules.base.controller;

import java.util.Map;

import com.dian.common.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.dian.common.controller.AbstractController;
import com.dian.modules.base.entity.WarehouseEntity;
import com.dian.modules.base.service.WarehouseService;
import com.dian.common.utils.PageUtils;
import com.dian.common.utils.R;

/**
 * 仓库信息
 *
 * @author Jinag Run
 * @email 1685269193qq.com
 * @date 2019-05-23 09:30:44
 */
@RestController
@Api("仓库信息接口")
@RequestMapping("base/warehouse")
public class WarehouseController extends AbstractController{
    @Autowired
    private WarehouseService baseWarehouseService;

    /**
     * 仓库信息列表
     */
    @SysLog("仓库信息列表")
    @GetMapping("/list")
    @ApiOperation("仓库信息列表")
    @RequiresPermissions("base:warehouse:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = baseWarehouseService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 仓库信息信息
     */
    @SysLog("仓库信息信息")
    @ApiOperation("仓库信息信息")
    @GetMapping("/info/{id}")
    @RequiresPermissions("base:warehouse:info")
    public R info(@PathVariable("id") Long id){
		WarehouseEntity baseWarehouse = baseWarehouseService.getById(id);

        return R.ok().put("warehouse", baseWarehouse);
    }

    /**
     * 仓库信息保存
     */
    @SysLog("仓库信息保存")
    @ApiOperation("仓库信息保存")
    @PostMapping("/save")
    @RequiresPermissions("base:warehouse:save")
    public R save(@RequestBody WarehouseEntity baseWarehouse){

		baseWarehouseService.saveInfo(baseWarehouse);

        return R.ok();
    }

    /**
     * 仓库信息修改
     */
    @SysLog("仓库信息修改")
    @ApiOperation("仓库信息修改")
    @PostMapping("/update")
    @RequiresPermissions("base:warehouse:update")
    public R update(@RequestBody WarehouseEntity baseWarehouse){

		baseWarehouseService.updateInfo(baseWarehouse);

        return R.ok();
    }

    /**
     * 仓库信息删除
     */
    @SysLog("仓库信息删除")
    @ApiOperation("仓库信息删除")
    @PostMapping("/delete")
    @RequiresPermissions("base:warehouse:delete")
    public R delete(@RequestBody Long[] ids){
		baseWarehouseService.deleteInfo(ids);

        return R.ok();
    }

}
